package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.SharedObject;
	
	public class GameOverPanel extends GameOver	{
		
		public static const PLAY_AGAIN:String = "playAgain";
		
		public function GameOverPanel()
		{
			playAgain.buttonMode = true;
			playAgain.addEventListener(MouseEvent.CLICK, function():void { dispatchEvent(new Event(PLAY_AGAIN)) } );
		}
		
		public function update(time:int):void {
			subTitle.text = "You finished in " + time + " seconds";
			var so:SharedObject = SharedObject.getLocal("mdbwordsearch");
			if (so.data.hiScores == "" || so.data.hiScores == null || so.data.hiScores.length<5) {
				var arr:Array = new Array(500, 500, 500, 500, 500);
				so.data.hiScores = arr;
				so.flush();
			}
			
			var scores:Array = String(so.data.hiScores).split(",");
			scores.push(time);
			scores.sort(Array.NUMERIC);
			scores.splice(5);
			so.data.hiScores = scores;
			so.flush();
			
			hiscore1.text = scores[0];
			hiscore2.text = scores[1];
			hiscore3.text = scores[2];
			hiscore4.text = scores[3];
			hiscore5.text = scores[4];
			
		}
		
	}

}